package com.wenwu.service.impl;

import com.wenwu.dao.DeptRepository;
import com.wenwu.pojo.Dept;
import com.wenwu.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: HWW
 * @Date: 2021/8/1616:05
 * @Desc:
 */
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptRepository deptRepository;

    //查找所有部门
    @Override
    public List<Dept> findList() {
        return deptRepository.findAll();
    }

    //根据ID查询部门信息
    @Override
    public Dept findById(String id) {
        return deptRepository.findById(id).get();
    }

    //添加部门
    @Override
    public void addDept(Dept dept) {
        deptRepository.save(dept);

    }

    //编辑部门
    @Override
    public void edit(Dept dept) {
        deptRepository.save(dept);
    }

    //根据ID删除部门
    @Override
    public void deleteById(String id) {
        deptRepository.deleteById(id);
    }
}
